feat: Use live solved counts for today's history entry in fetch-user-info.js (#265)#339
Open
yashvi-3106 wants to merge 1 commit into
Open
feat: Use live solved counts for today's history entry in fetch-user-info.js (#265)#339yashvi-3106 wants to merge 1 commit into
yashvi-3106 wants to merge 1 commit into
Conversation
Contributor
|
Thank you for submitting a pull request. Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully. Formatting and Branching
|
jagdish-15
requested changes
Jul 18, 2026
| @@ -85,6 +91,25 @@ async function fetchUserInfo(username) { | |||
| history = Array.isArray(history) ? history : []; | |||
| history.sort((a, b) => new Date(a.date) - new Date(b.date)); | |||
Collaborator
There was a problem hiding this comment.
Could you move this sorting line below the logic where we insert today's count? While today's entry will technically always be the most recent date, it's generally safer and better practice to sort the array after all insertions or modifications have been made. That way the data is guaranteed to be in the correct order regardless of how it's constructed in the future.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Previously, the user profile page loaded stale solved count metrics for the current day because historical user data is only updated during the scheduled sync interval (every 15 minutes).
This PR updates the
/api/user/:usernameendpoint to extract live solved counts (easySolved,mediumSolved,hardSolved) from the LeetCode wrapper API and dynamically overwrite (or insert) today's history entry with these live values.Linked Issue
Fixes #265
Changes Made
fetchUserInfo()inscripts/fetch-user-info.jsto extracteasySolved,mediumSolved, andhardSolvedcounts from the wrapper API response.YYYY-MM-DDdate matching).Type of Change
Testing
Checklist
npx prettier --write .before submittingfeature/*branch, not themainbranch